const treeData = require("./treeData");
const { clone } = require("../cloneDeep");
 
function getPaths(treeData, name) {
  return treeData.filter((item) => {
    if (item.name.includes(name)) {
      item.children = [];
      return true;
    }
    if (item?.children?.length) {
      const arr = getPaths(item.children, name);
      if (arr.length) {
        item.children = arr;
        return true;
      }
    }
  });
}
const nodes = getPaths(treeData, "Node 1-1");
console.dir(nodes);
